package com.datawin.taotaocheche.ui.actviity.user.presenter;

import java.util.List;

import javax.inject.Inject;

import com.datawin.taotaocheche.base.BaseBiz;
import com.datawin.taotaocheche.bean.UserInfo;
import com.datawin.taotaocheche.comm.MyApplication;
import com.datawin.taotaocheche.ui.actviity.user.biz.DrawBackBiz;
import com.datawin.taotaocheche.ui.actviity.user.contract.DrawBackContract;

/**
 * Created by Administrator on 2017/10/21.
 */

public class DrawBackPresenter implements DrawBackContract.Presenter {

    DrawBackContract.View view;
    DrawBackBiz drawBackBiz;


    @Inject
    public DrawBackPresenter(DrawBackContract.View view) {
        this.view = view;
    }


    @Override
    public void setBiz(BaseBiz biz) {
        drawBackBiz=(DrawBackBiz) biz;
    }

    @Override
    public void getUserInfo() {
        drawBackBiz.getUserInfo(MyApplication.userInfo.getUserCode(), new BaseBiz.Callback<List<UserInfo>>() {
            @Override
            public void onSuccess(List<UserInfo> o) {
                view.upDateUI(o.get(0));
            }

            @Override
            public void onFailure(List<UserInfo> o) {

            }
        });
    }


    @Override
    public void darwBack() {
        drawBackBiz.drawBack(MyApplication.userInfo.getUserCode(),  new BaseBiz.Callback<Object>() {
            @Override
            public void onSuccess(Object info) {
                view.showMsg("申请退款成功");
                view.loading(false);
                view.finishAct();
            }

            @Override
            public void onFailure(Object info) {
                view.loading(false);
            }
        });
    }
}
